/// @tags: DP
#include <algorithm>
#include <cstdio>
#include <iostream>

using namespace std;

namespace BlueQuantum {

typedef long long LL;

constexpr int MAXN = 5e1 + 3, P = 998244353;

int n;
int a[MAXN], b[MAXN], disc[MAXN * 2], f[MAXN], C[MAXN];

inline LL qpow(LL base, int exp = P - 2) {
  LL res = 1;
  while (exp) {
    if (exp & 1) res = res * base % P;
    exp >>= 1;
    base = base * base % P;
  }
  return res;
}

inline int inc(int x, int y) {
  x += y;
  return x >= P ? x - P : x;
}

inline int dec(int x, int y) {
  x -= y;
  return x < 0 ? x + P : x;
}

inline int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i] >> b[i];
    disc[++*disc] = a[i];
    disc[++*disc] = ++b[i];
  }
  sort(disc + 1, disc + *disc + 1);
  *disc = unique(disc + 1, disc + *disc + 1) - disc - 1;
  for (int i = 1; i <= n; ++i) {
    a[i] = lower_bound(disc + 1, disc + *disc + 1, a[i]) - disc;
    b[i] = lower_bound(disc + 1, disc + *disc + 1, b[i]) - disc;
  }
  f[0] = 1;
  for (int j = *disc - 1; j; --j) {
    int len = disc[j + 1] - disc[j];
    C[0] = 1;
    for (int i = 1; i <= n; ++i) C[i] = (LL)C[i - 1] * (len + i - 1) % P * qpow(i) % P;
    for (int i = n; i >= 1; --i)
      if (a[i] <= j && j < b[i])
        for (int cnt = 1, k = i - 1; k >= 0; --k, ++cnt) {
          f[i] = inc(f[i], (LL)C[cnt] * f[k] % P);
          if (a[k] > j || j >= b[k]) break;
        }
  }
  LL ans = f[n];
  for (int i = 1; i <= n; ++i) ans = ans * qpow(disc[b[i]] - disc[a[i]]) % P;
  cout << ans;
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("CF1295F Good Contest.in", "r", stdin);
  freopen("CF1295F Good Contest.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
